﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace BLL.SysManage
{
    public class T_PUB_DEPARTMENT
    {
        private readonly DALL.SysManage.T_PUB_DEPARTMENT dal = new DALL.SysManage.T_PUB_DEPARTMENT();



        /// <summary>
        /// 智能提示部门名称
        /// </summary>
        /// <param name="branch_id"></param>
        /// <returns></returns>
        public DataSet GetDepartmentName()
        {
            return dal.GetDepartmentName();
        }

        /// <summary>
        /// 获得下降所有部门
        /// </summary>
        /// <param name="strPIPD">父ID</param>
        /// <param name="strNmae">名称</param>
        /// <returns></returns>
        public List<Model.SysManage.T_PUB_DEPARTMENT> GetNxtDepartMent(string strPIPD, string strNmae)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("  1>0 ");
            if (strPIPD != "" && strPIPD!=null)
            {
                strSql.Append(string.Format(" and PARENTID='{0}'", strPIPD));
            }
            if (!string.IsNullOrEmpty(strNmae))
            {
                strSql.Append(string.Format(" and DEPARTMENT_NAME like'%{0}%'", strNmae));
            }
            return GetModelList(strSql.ToString());
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.SysManage.T_PUB_DEPARTMENT model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(Model.SysManage.T_PUB_DEPARTMENT model)
        {
            dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int DEPARTMENT_ID)
        {

            return dal.Delete(DEPARTMENT_ID);
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.SysManage.T_PUB_DEPARTMENT GetModel(int DEPARTMENT_ID)
        {

            return dal.GetModel(DEPARTMENT_ID);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.SysManage.T_PUB_DEPARTMENT> GetModelList(string strWhere)
        {
            return dal.GetListArray(strWhere);
        }
    }
}
